diff --git a/web/pgadmin/static/js/sqleditor_utils.js b/web/pgadmin/static/js/sqleditor_utils.js index 876aa52..912aa7f 100644 --- a/web/pgadmin/static/js/sqleditor_utils.js +++ b/web/pgadmin/static/js/sqleditor_utils.js @@ -8,8 +8,8 @@ ////////////////////////////////////////////////////////////////////////// // This file contains common utilities functions used in sqleditor modules -define(['jquery'], - function ($) { +define(['jquery', 'sources/gettext'], + function ($, gettext) { var sqlEditorUtils = { /* Reference link http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript * Modified as per requirement. @@ -55,6 +55,63 @@ define(['jquery'], }, capitalizeFirstLetter: function (string) { return string.charAt(0).toUpperCase() + string.slice(1); + }, + updateConnectionStatus: function(url, poll_time) { + // This function will update the connection status + var $el = $(".connection_status"), + $blink_circle = $($el).find(".blink_circle"); + + setInterval(function(){ + $.ajax({ + url: url, + method: 'GET', + success: function (res) { + if(res && res.data) { + var status = res.data.status, + msg = res.data.message; + // Set tooltip + $el.prop('title', msg); + // change color + switch(status) { + // Busy + case 1: + $blink_circle.removeClass("connection_idle") + .removeClass("connection_failed") + .addClass('connection_busy'); + break; + // Failed + case 3: + case 4: + $blink_circle.removeClass("connection_idle") + .removeClass("connection_busy") + .addClass('connection_failed'); + break; + default: + $blink_circle.removeClass("connection_failed") + .removeClass("connection_busy") + .addClass('connection_idle'); + } + } + }, + error: function (e) { + var msg = gettext("Transaction status check failed."); + if (e.readyState == 0) { + msg = gettext("Not connected to the server or the connection to " + + "the server has been closed."); + } + if (e.responseJSON && e.responseJSON.errormsg) { + msg = e.responseJSON.errormsg; + } + + // Set tooltip + $el.prop('title', msg); + // Error + $blink_circle.removeClass("connection_idle") + .removeClass("connection_busy") + .addClass('connection_failed'); + } + }); + }, poll_time * 1000); } }; return sqlEditorUtils; diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html index ff4368d..f2ba5ba 100644 --- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html +++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html @@ -1,8 +1,5 @@ {% extends "base.html" %} {% block title %}{{ config.APP_NAME }} - Datagrid{% endblock %} -{% block css_link %} - -{% endblock %} {% block body %}